package com.hulk.dryad.manage.framework.websocket.server.config;


import com.hulk.dryad.manage.framework.websocket.server.user.DefaultWsUserStore;
import com.hulk.dryad.manage.framework.websocket.server.user.IWsUserManage;
import com.hulk.dryad.manage.framework.websocket.server.user.IWsUserStore;
import com.hulk.dryad.manage.framework.websocket.server.user.WsUserManageImpl;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * websocket 账号管理
 *
 * @author hulk
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(
	name = "userStore.enabled",
	prefix = WebSocketServerProperties.PREFIX,
	havingValue = "true"
)
public class WebSocketUserManageConfiguration {

	@Bean
	public IWsUserManage wsUserManage(ObjectProvider<IWsUserStore> provider) {
		IWsUserStore wsUserStore = provider.getIfAvailable(DefaultWsUserStore::new);
		return new WsUserManageImpl(wsUserStore);
	}

}
